import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from  DateDialog import DateDialog
class WindowDemo(QWidget):
    def __init__(self,parent=None):
        super(WindowDemo,self).__init__(parent)
        self.resize(400,100)
        self.setWindowTitle("多窗口数据传递")
        self.lineedit=QLineEdit(self)
        self.button1=QPushButton('弹出对话框1')
        self.button1.clicked.connect(self.onButton1Click)
        self.button2 = QPushButton('弹出对话框2')
        self.button2.clicked.connect(self.onButton2Click)
        grid=QGridLayout()
        grid.addWidget(self.lineedit)
        grid.addWidget(self.button1)
        grid.addWidget(self.button2)
        self.setLayout(grid)
    def onButton1Click(self):
        dialog=DateDialog(self)
        result=dialog.exec_()
        date=dialog.dateTime()
        self.lineedit.setText(date.date().toString())
        print(result)
        dialog.destroy()
    def onButton2Click(self):
        date,time,result=DateDialog.getDateTime()
        self.lineedit.setText(date.toString())
        print(result)

        if result==QDialog.Accepted:
            print("确认")
        else:
            print("取消")

if __name__ == '__main__':
    app=QApplication(sys.argv)
    main=WindowDemo()
    main.show()
    sys.exit(app.exec_())